package com.wcl.demo.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.easemob.chat.EMGroupInfo;
import com.wcl.demo.R;
import java.util.List;

/**
 * Created by dllo on 15/11/24.
 */
public class AddPublicGroupAdapter extends RecyclerView.Adapter<AddPublicGroupAdapter.AddPublicGroupAdapterViewHolder> {
    private List<EMGroupInfo> list;
    public void addData(List<EMGroupInfo> list){
        this.list = list;
        notifyDataSetChanged();
    }

    class AddPublicGroupAdapterViewHolder extends RecyclerView.ViewHolder {
        private TextView friends;
        public AddPublicGroupAdapterViewHolder(View itemView) {
            super(itemView);
            friends = (TextView) itemView.findViewById(R.id.friends);
        }
    }

    @Override
    public AddPublicGroupAdapterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.recyclerview_friends_item , null);
        return new AddPublicGroupAdapterViewHolder(view);
    }

    @Override
    public void onBindViewHolder(AddPublicGroupAdapterViewHolder holder, int position) {
        holder.friends.setText(list.get(position).getGroupName());
    }

    @Override
    public int getItemCount() {
        return list != null && list.size() > 0 ? list.size() : 0;
    }

}
